/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifMostrarAlertas.java
 *
 * Created on 03-sep-2010, 14:18:17
 */

package Utiles;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Listas;
import administracion.helper.MiTablePrint;
import administracion.helper.Utiles_Tabla;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.AlertaTO;

/**
 *
 * @author Diana
 */
public class jifMostrarAlertas extends javax.swing.JInternalFrame {
    private JTableBinding jTableBinding;
    private BindingGroup bindingGroup;
    List<AlertaTO> alertas;
    /** Creates new form jifMostrarAlertas */
    public jifMostrarAlertas() {
        initComponents();
        try {
            alertas = Listas.getAlertas();
        } catch (Exception ex) {
            Logger.getLogger(jifMostrarAlertas.class.getName()).log(Level.SEVERE, null, ex);
        }
        cargarDatos();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
     public void cargarDatos(){
    this.bindingGroup = new BindingGroup();
    this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.alertas, this.jtfAlerta);

    JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${desc_tipo}"));

    columnBinding0.setColumnName("DESCRIPCION");
    columnBinding0.setColumnClass(String.class);
    columnBinding0.setEditable(false);

    JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${descripcion}"));

    columnBinding1.setColumnName("DESCRIPCION ADICIONAL");
    columnBinding1.setColumnClass(String.class);
    columnBinding1.setEditable(false);

    JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${fecha}"));

    columnBinding2.setColumnName("FECHA");
    columnBinding2.setColumnClass(String.class);
    columnBinding2.setEditable(false);


    this.bindingGroup.addBinding(this.jTableBinding);
    this.bindingGroup.bind();
    try {
          int[] porcentajes= {40,40,20};
        Utiles_Tabla.definirAnchoColumnasJTable(this.jtfAlerta, porcentajes);
        } catch (Exception ex) {
            Logger.getLogger(jifMostrarAlertas.class.getName()).log(Level.SEVERE, null, ex);
        }

  }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jtfAlerta = new javax.swing.JTable();
        jbtCancelar = new javax.swing.JButton();

        setIconifiable(true);
        setTitle("CONSULTA DE ALERTAS");

        jtfAlerta.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "TIPO ALERTA", "DESCRIPCION", "FECHA"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jtfAlerta);

        jbtCancelar.setFont(new java.awt.Font("Arial", 1, 12));
        jbtCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbtCancelar.setText("CANCELAR");
        jbtCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(247, 247, 247)
                        .addComponent(jbtCancelar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbtCancelar)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtCancelarActionPerformed
        this.dispose();
}//GEN-LAST:event_jbtCancelarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtCancelar;
    private javax.swing.JTable jtfAlerta;
    // End of variables declaration//GEN-END:variables

}
